home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { Turbo Pascal Version 6.0 }
- { Turbo Vision Unit }
- { }
- { Copyright (c) 1990 Borland International }
- { }
- {*******************************************************}
-
-
- { Módulo de diálogos modificado para su uso con Mdiskpro y EmiApp }
- { modificaciones (c) Emilio David Diaus López 1994 }
-
- Unit Emimsbox;
-
- {$F+,O+,X+,D-,S-,L-,R-}
-
- Interface
-
- Uses Objects;
-
- Const
-
- { Message box classes }
-
- Mfwarning = $0000; { Display a Warning box }
- Mferror = $0001; { Dispaly a Error box }
- Mfinformation = $0002; { Display an Information Box }
- Mfconfirmation = $0003; { Display a Confirmation Box }
-
- { Message box button flags }
-
- Mfyesbutton = $0100; { Put a Yes button into the dialog }
- Mfnobutton = $0200; { Put a No button into the dialog }
- Mfokbutton = $0400; { Put an OK button into the dialog }
- Mfcancelbutton = $0800; { Put a Cancel button into the dialog }
-
- Mfyesnocancel = Mfyesbutton + Mfnobutton + Mfcancelbutton;
- { Standard Yes, No, Cancel dialog }
- Mfokcancel = Mfokbutton + Mfcancelbutton;
- { Standard OK, Cancel dialog }
-
- { MessageBox displays the given string in a standard sized }
- { dialog box. Before the dialog is displayed the Msg and Params }
- { are passed to FormatStr. The resulting string is displayed }
- { as a TStaticText view in the dialog. }
-
- Function Messagebox(Msg: String; Params: Pointer; Aoptions: Word): Word;
-
- { MessageBoxRec allows the specification of a TRect for the }
- { message box to occupy. }
-
- Function Messageboxrect(Var R: Trect; Msg: String; Params: Pointer;
- Aoptions: Word): Word;
-
- { InputBox displays a simple dialog that allows the user to }
- { type in a string. }
-
- Function Inputbox(Title: String; Alabel: String; Var S: String;
- Limit: Byte): Word;
-
- { InputBoxRect is like InputBox but allows the specification of }
- { a rectangle. }
-
- Function Inputboxrect(Var Bounds: Trect; Title: String; Alabel: String;
- Var S: String; Limit: Byte): Word;
-
- Implementation
-
- Uses Drivers, Views, Dialogs, Emiapp;
-
- Function Messagebox(Msg: String; Params: Pointer;
- Aoptions: Word): Word;
- Var
- R: Trect;
- Begin
- R.Assign(0, 0, 40, 9);
- R.Move((Desktop^.Size.X - R.B.X) Div 2, (Desktop^.Size.Y - R.B.Y) Div 2);
- Messagebox := Messageboxrect(R, Msg, Params, Aoptions);
- End;
-
- Function Messageboxrect(Var R: Trect; Msg: String; Params: Pointer;
- Aoptions: Word): Word;
- Const
- Buttonname: Array[0..3] Of String[10] =
- ('~S~i', '~N~o', 'O~K~', '~C~ancelar');
- Commands: Array[0..3] Of Word =
- (Cmyes, Cmno, Cmok, Cmcancel);
- Titles: Array[0..3] Of String[11] =
- ('Advertencia','Error','Información','Confirmar');
- Var
- I, X, Buttoncount: Integer;
- Dialog: Pdialog;
- Control: Pview;
- T: Trect;
- Buttonlist: Array[0..4] Of Pview;
- S: String;
- Begin
- Dialog := New(Pdialog,
- Init(R, Titles[Aoptions And $3]));
- With Dialog^ Do
- Begin
- R.Assign(3, 2, Size.X - 2, Size.Y - 3);
- Formatstr(S, Msg, Params^);
- Control := New(Pstatictext, Init(R, S));
- Insert(Control);
- X := -2;
- Buttoncount := 0;
- For I := 0 To 3 Do
- If Aoptions And ($0100 Shl I) <> 0 Then
- Begin
- R.Assign(0, 0, 12, 2);
- Control := New(Pbutton, Init(R, Buttonname[I], Commands[I],
- Bfnormal));
- Inc(X, Control^.Size.X + 4);
- Buttonlist[Buttoncount] := Control;
- Inc(Buttoncount);
- End;
- X := (Size.X - X) Shr 1;
- For I := 0 To Buttoncount - 1 Do
- Begin
- Control := Buttonlist[I];
- Insert(Control);
- Control^.Moveto(X, Size.Y - 3);
- Inc(X, Control^.Size.X + 2);
- End;
- Selectnext(False);
- End;
- Messageboxrect := Desktop^.Execview(Dialog);
- Dispose(Dialog, Done);
- End;
-
- Function Inputbox(Title: String; Alabel: String; Var S: String;
- Limit: Byte): Word;
- Var
- R: Trect;
- Begin
- R.Assign(0, 0, 60, 8);
- R.Move((Desktop^.Size.X - R.B.X) Div 2, (Desktop^.Size.Y - R.B.Y) Div 2);
- Inputbox := Inputboxrect(R, Title, Alabel, S, Limit);
- End;
-
- Function Inputboxrect(Var Bounds: Trect; Title: String; Alabel: String;
- Var S: String; Limit: Byte): Word;
- Var
- Dialog: Pdialog;
- Control: Pview;
- R: Trect;
- C: Word;
- Begin
- Dialog := New(Pdialog, Init(Bounds, Title));
- With Dialog^ Do
- Begin
- R.Assign(4 + Cstrlen(Alabel), 2, Size.X - 3, 3);
- Control := New(Pinputline, Init(R, Limit));
- Insert(Control);
- R.Assign(2, 2, 3 + Cstrlen(Alabel), 3);
- Insert(New(Plabel, Init(R, Alabel, Control)));
- R.Assign(Size.X - 30, Size.Y - 4, Size.X - 20, Size.Y - 2);
- Insert(New(Pbutton, Init(R, 'O~K~', Cmok, Bfdefault)));
- Inc(R.A.X, 12); Inc(R.B.X, 16);
- Insert(New(Pbutton, Init(R, '~C~ancelar', Cmcancel, Bfnormal)));
- Inc(R.A.X, 12); Inc(R.B.X, 12);
- Selectnext(False);
- End;
- Dialog^.Setdata(S);
- C := Desktop^.Execview(Dialog);
- If C <> Cmcancel Then Dialog^.Getdata(S);
- Dispose(Dialog, Done);
- Inputboxrect := C;
- End;
-
- End.
-